// pages/orderdetails/orderdetails.js
import http from "../../../../utils/http.js"
var timestamp = require('../../../utils/timestamp')
Page({
  data: {
    orderAllInfo:{},
    createTime:""

  },
  onLoad: function (options) {
    this.orderNo = options.orderNo
  },
//订单详情
  async getMyOrderInfo(){
    let userId = wx.getStorageSync('user').user.id
    let token = wx.getStorageSync('user').token
    let option = {
       url:"/venueOrder/getMyOrderInfo",
       data:{
        orderNo:this.orderNo,
        userId,
        token
        // orderNo: this.orderNo,
        // userId,
        // token
       }
    }
    let res = await http(option)
    console.log(res);
    if(res.data.status == 200){
      // this.orderNo = "1641349440914420294"
      this.setData({
        orderAllInfo:res.data.data
      },()=>{
      let time =new Date( this.data.orderAllInfo.orderInfo.createTime)
     let createTime  = timestamp.formatTime(time,'Y/M/D h:m:s')
     this.setData({
      createTime
     })
      })
    }
  },
  onShow: function () {
    this.getMyOrderInfo()
      },
  //返回上一页
  return() {
    wx.navigateBack({
      delta: 1,
    })
  },
  //跳转到电子券
  toTicket() {
    wx.navigateTo({
      url: '../ticket/ticket?orderNo='+this.orderNo,
    })
  },
  // 取消支付弹框
  cancel() {
    wx.showModal({
      confirmColor: "#f00",
      title: '提示',
      content: "您确定要取消该订单吗?",
      success(res) {
        if (res.confirm) {
          console.log('用户点击确定')
        } else if (res.cancel) {
          console.log('用户点击取消')
        }
      }
    })
  },
  // 跳转到支付成功页面
  toPayment() {
    wx.navigateTo({
      url: '../payment/payment'
    })
  },
  //打电话给商家
  callPhone(){
    wx.makePhoneCall({
      phoneNumber: this.data.orderAllInfo.store.mobile,
      success(res){
      }
    })
  },
  onReady: function () {

  },
  onHide: function () {

  },
  onUnload: function () {

  },
  onPullDownRefresh: function () {

  },
  onReachBottom: function () {

  },
  onShareAppMessage: function () {

  }
})